<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>editmenu</title>
<link rel="stylesheet" type="text/css" href="250524.css" />
</head>
<?php
$link = @mysql_pconnect("localhost","lele","happy"); 
mysql_query("SET NAMES 'utf8'");
mysql_select_db("LELE_restaurant");
?>
<script type="text/javascript" src="jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function () {
	$("form#submit").submit(function() {
	// we want to store the values from the form input box, then send via ajax below
	var dishtype     = $('#dishtype').attr('value');
	var dishname     = $('#dishname').attr('value');
	var shortname     = $('#shortname').attr('value');
	var dishprice     = $('#dishprice').attr('value');
	var comments     = $('#comments').attr('value');
		
	if( dishtype == "" || dishname == "" || shortname == "" || dishprice == "")
	{
		alert('不能空白');
		return false;
	}
	
		
		$.ajax({
			type: "POST",
			url: "insert.php",
			data: "dishtype="+ dishtype + "&dishname=" + dishname+ "&shortname=" + shortname+ "&dishprice=" + dishprice+ "&comments=" + comments,
			success: function(){
				//$('form#submit').hide();
				//$('div.success').fadeIn();
				location.reload();
			}
			
		});
	return false;
	});
	
})
var XMLHttpRequestObject = false;
if (window.XMLHttpRequest) 
{
  XMLHttpRequestObject = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
  XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHttp");
}

function getData(dataSource, divID)
{
  if(XMLHttpRequestObject)
  {
    XMLHttpRequestObject.open("GET", dataSource);
    XMLHttpRequestObject.onreadystatechange = function()
    {
      if (XMLHttpRequestObject.readyState == 4 &&
          XMLHttpRequestObject.status == 200)
      {
        var objDiv = document.getElementById(divID);
        objDiv.innerHTML = XMLHttpRequestObject.responseText;
      }
    }
    XMLHttpRequestObject.send(null);
  }
}

function checkUsername(keyEvent, divID)
{
  keyEvent = (keyEvent) ? keyEvent: window.event;
  input = (keyEvent.target) ? keyEvent.target : keyEvent.srcElement;
  if (keyEvent.type == "keyup")
  {
    var objDiv = document.getElementById(divID);
    objDiv.innerHTML = "<div></div>";
    if (input.value)
    {
      getData("login_check.php?qry="+input.value, divID);
    }
  }
}


</script>




<body>
	<div id="wrapper">
         <div id="header">
		       <h1>小樂飯麵</h1>
		 </div>
         <div id="navigation">
         <button id="navibutton" type="button" onclick="window.history.back()">回上一頁</button>
         	   
		 </div>
		 <div id="content">
		      
				<?php
				print "<p>Menu information</p>"; 
				print "</p><table border=1><tr><td>類型</td><td>料理名稱</td><td>料理簡碼</td><td>價格</td><td>註解</td></tr>";

				$result = mysql_query("select * from menu");

				while ($row=mysql_fetch_row($result)) 
				{ 
					print "<tr><td>" . $row[0] . "</td><td>" . $row[1] . "</td><td>" .  $row[2]."</td><td>".  $row[3]."</td><td>".  $row[4]
					."</td></tr>"; 
				}
				print "</table>";
				?>
		 </br></br></br>
		 <form id="submit" method="post" name="submit" action="">
		 
		 <table border=1><tr><td>類型</td><td>料理名稱</td><td>料理簡碼</td><td>價格</td><td>註解</td><td>&emsp;&emsp;&emsp;&emsp;&emsp;</td></tr>
		 <tr><td>
		 <!--<input type="text" name="dishtype" id="dishtype" class="text" size="20" />-->
		 炒飯類<input type="radio" name="dishtype" id="dishtype" value="1"/></br>
		 麵類<input type="radio" name="dishtype" id="dishtype" value="2"/></br>
		 小菜飲料<input type="radio" name="dishtype" id="dishtype" value="3" /></br></td>
		 <td>
		 <input type="text" name="dishname" id="dishname" class="text" size="20" /></td>
		 
		 <td>
		 <input type="text" name="shortname" id="shortname" class="text" size="20" /></td>

		 <td>
		 <input type="text" name="dishprice" id="dishprice" class="text" size="20" /></td>
		 
		 <td>

		 <textarea rows=4 name="comments" id="comments" class="text"></textarea></td>
		 <td><button type="submit" value="send" id="btn">儲存</button></td>
		 <td><button type="reset" value="clear" id="clear_btn">清除</button></td></tr>
		 </table>
		 
		 </form>
	
		<div id="msg"> </div>
	
		 </div>
		 <div id="footer">
		       
			   <p>This is the Footer</p>		
			    
	     </div>   </div>
   
</body>
</html>
